package com.ding.operation.controller;


import com.ding.operation.entity.OperationDto;
import com.ding.operation.entity.RecordOpreation;
import com.ding.operation.service.IRecordOpreationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Ding
 * @since 2022-07-21
 */
@Api(tags = "日志操作模块")
@RestController
@RequestMapping("/record-opreation")
public class RecordOpreationController {

    @Autowired
    private IRecordOpreationService recordOpreationService;

    @ApiOperation(value = "新增日志操作信息", notes = "用户操作")
    @PostMapping("/addLogger")
    public String addLogger(@RequestBody OperationDto operationDto){

        RecordOpreation recordOpreation = new RecordOpreation();
        recordOpreation.setTime(new Date());
        recordOpreation.setUser("admin");

        BeanUtils.copyProperties(operationDto,recordOpreation);

        boolean save = recordOpreationService.save(recordOpreation);

        if(save){
            return "增加成功";
        }else{
            return "增加失败";
        }

    }


}

